/**
 * @copyright (c) YX Company.
 */
package com.ry.core.base.common;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 分页信息类
 * 
 * @author chengl
 * @Date 2011-8-16
 * @version 1.0
 */
public class Page<T> {

	/**
	 * 当前第几页
	 */
	private int page = 1;

	/**
	 * 每页记录数
	 */
	private int pageSize = 10;

	/**
	 * 记录总数
	 */
	private int totalSize;

	/**
	 * 排序规则：升序(asc) or 降序(desc)
	 */
	private String dir = "asc";

	/**
	 * 排序字段
	 */
	private String sort = "id";

	/**
	 * 业务对象集合
	 */
	private List<T> collection;

	/**
	 * 用于存放其他的数据
	 */
	private Map<String, Object> map = new HashMap<String, Object>();

	public Map<String, Object> getMap() {
		return map;
	}

	public void setMap(Map<String, Object> map) {
		this.map = map;
	}

	public List<T> getCollection() {
		return collection;
	}

	public void setCollection(List<T> collection) {
		this.collection = collection;
	}

	public int getTotalSize() {
		if (totalSize == 0) {
			totalSize = collection.size();
		}
		return totalSize;
	}

	public void setTotalSize(int totalSize) {
		this.totalSize = totalSize;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String getDir() {
		return dir;
	}

	public void setDir(String dir) {
		this.dir = dir;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}
}
